from rest_framework import serializers

from apps.goods.models import SPUSpecification



class SpecSerializer(serializers.ModelSerializer):
    """
    规格表序列化器
    """

    # 关联嵌套返回spu表的商品名
    spu = serializers.StringRelatedField(read_only=True)
    # 返回关联的spu的id
    spu_id = serializers.IntegerField()

    class Meta:
        model = SPUSpecification
        fields = "__all__"